//
//  MSSeeStatisticsCell.m
//  觅尚
//
//  Created by No.8 on 2019/4/10.
//  Copyright © 2019 No.8. All rights reserved.
//

#import "MSSeeStatisticsCell.h"

@implementation MSSeeStatisticsCell
- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self CreatView];
    }
    return self;
}
- (void)CreatView{
    
    /** 背景*/
    self.backView = [[UIView alloc] initWithFrame:CGRectZero];
    
//    self.backView.layer.borderWidth = 1;
//    self.backView.layer.borderColor = WYCRGBColor(75, 60, 53).CGColor;
    [self addSubview:self.backView];
    
    
    /** 头像*/
    self.PhotoIMG = [[UIImageView alloc] initWithFrame:CGRectZero];
    [self.backView addSubview:self.PhotoIMG];
//    //绘制圆角 要设置的圆角 使用“|”来组合
//    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.PhotoIMG.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(30 * px, 30 * px)];
//    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
//    //设置大小
//    maskLayer.frame = self.PhotoIMG.bounds;
//    //设置图形样子
//    maskLayer.path = maskPath.CGPath;
//    self.PhotoIMG.layer.mask = maskLayer;
    
    
    
    self.listPhotoIMG = [[UIImageView alloc] initWithFrame:CGRectZero];
    [self.backView addSubview:self.listPhotoIMG];
    
    /** 姓名*/
    self.NameLable = [[UILabel alloc] initWithFrame:CGRectZero];
   
    [self.backView addSubview:self.NameLable];
    
    
    /** 姓名*/
    self.departmentLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    
    [self.backView addSubview:self.departmentLabel];
    
    /** 按钮*/
    self.SexButton = [[MSSexButton alloc] initWithFrame:CGRectZero];
    
    [self.backView addSubview:self.SexButton];
    
    /** 身高*/
    self.heightLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    
    [self.backView addSubview:self.heightLabel];
    
    
    /** 身高*/
    self.addressLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    
    [self.backView addSubview:self.addressLabel];
    
    
    self.attendanceLabel = [[UILabel alloc] initWithFrame:CGRectZero];
    [self.backView addSubview:self.attendanceLabel];
    
    
    self.speLabel = [[UILabel alloc] init];
    [self.backView addSubview:self.speLabel];
    
    self.listNameLable = [[UILabel alloc] initWithFrame:CGRectZero];
    [self.backView addSubview:self.listNameLable];
    
    
//    self.lineView = [[UIView alloc] init];
//    self.lineView.backgroundColor = backgroundcolor;
//    [self.backView addSubview:self.lineView];
    
}

- (void)setIsGrid:(BOOL)isGrid{
    
    _isGrid = isGrid;
    
    if (isGrid == YES) {
        //方格
//        self.backView.frame = CGRectMake(20 * px, 0, ScreenWidth / 2 - 40 * px , 680 * px);
//        self.backView.layer.cornerRadius = 30 * px;
//        self.backView.layer.masksToBounds = YES;
//        self.backView.backgroundColor = [UIColor whiteColor];
//
//        self.PhotoIMG.frame = CGRectMake(0, 0, self.backView.width, 500 * px);
//        self.PhotoIMG.backgroundColor = [UIColor grayColor];
//
//
//
//         CGSize size = [self.AttendanceListModel.userName sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:SYRealValue(28 / 2)]}];
//
//        self.NameLable.frame = CGRectMake(20 * px, CGRectGetMaxY(self.PhotoIMG.frame) + 20 * px, size.width, 60 * px);
//        self.NameLable.textColor = [UIColor blackColor];
//        self.NameLable.text = @"柳林东";
//        self.NameLable.textAlignment = NSTextAlignmentLeft;
//        self.NameLable.font = [UIFont systemFontOfSize:SYRealValue(26 / 2)];
//
//        self.departmentLabel.frame = CGRectMake(CGRectGetMaxX(self.NameLable.frame) + 10 * px, self.NameLable.y, self.NameLable.width * 2, self.NameLable.height);
//        self.departmentLabel.textColor = [UIColor grayColor];
//        self.departmentLabel.text = @"(营业部)";
//        self.departmentLabel.textAlignment = NSTextAlignmentLeft;
//        self.departmentLabel.font = [UIFont systemFontOfSize:SYRealValue(26 / 2)];
//
//
//        self.SexButton.frame = CGRectMake(self.NameLable.x, CGRectGetMaxY(self.NameLable.frame) + 20 * px, 100 * px, 40 * px);
//        [self.SexButton  setImage:[UIImage imageNamed:@"女"] forState:UIControlStateNormal];
//        [self.SexButton setTitle:@"23" forState:UIControlStateNormal];
//        self.SexButton.backgroundColor = WYCRGBColor(239, 138, 139);
//        self.SexButton.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(20 / 2)];
//        [self.SexButton  setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//        self.SexButton.layer.cornerRadius = 5 * px;
//
//
//        self.heightLabel.frame = CGRectMake(CGRectGetMaxX(self.SexButton.frame) + 10 * px, self.SexButton.y, 100 * px, self.SexButton.height);
//        self.heightLabel.textColor = self.SexButton.titleLabel.textColor;
//        self.heightLabel.text = @"165cm";
//        self.heightLabel.layer.cornerRadius = 5 * px;
//        self.heightLabel.backgroundColor = WYCRGBColor(109, 128, 152);
//        self.heightLabel.textAlignment = NSTextAlignmentCenter;
//        self.heightLabel.font = [UIFont systemFontOfSize:SYRealValue(20 / 2)];
//
//
//        self.addressLabel.frame = CGRectMake(CGRectGetMaxX(self.heightLabel.frame) + 10 * px, self.SexButton.y, 150 * px, self.SexButton.height);
//        self.addressLabel.textColor = [UIColor whiteColor];
//        self.addressLabel.text = @"中国河北";
//        self.addressLabel.layer.cornerRadius = 5 * px;
//        self.addressLabel.backgroundColor = WYCRGBColor(109, 128, 152);
//        self.addressLabel.textAlignment = NSTextAlignmentCenter;
//        self.addressLabel.font = [UIFont systemFontOfSize:SYRealValue(20 / 2)];
        
//        self.lineView.backgroundColor = [UIColor redColor];
        self.lineView.hidden = YES;
        
    }else{
        
        
        
    }
}

- (void)setAttendanceListModel:(MSAttendanceListModel *)AttendanceListModel{
    _AttendanceListModel = AttendanceListModel;
    if (_isGrid == YES) {
        
        self.backView.frame = CGRectMake(20 * px, 0, ScreenWidth / 2 - 40 * px , 680 * px);
        self.backView.layer.cornerRadius = 30 * px;
        self.backView.layer.masksToBounds = YES;
        self.backView.backgroundColor = [UIColor whiteColor];
        
        self.PhotoIMG.frame = CGRectMake(0, 0, self.backView.width, 500 * px);
        [self.PhotoIMG sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",AttendanceListModel.avatarUrl]] placeholderImage:[UIImage imageNamed:@"我的占位头像"]];
        self.PhotoIMG.backgroundColor = [UIColor grayColor];
        
        
        
        CGSize size = [self.AttendanceListModel.userName sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:SYRealValue(28 / 2)]}];
        
        self.NameLable.frame = CGRectMake(20 * px, CGRectGetMaxY(self.PhotoIMG.frame) + 20 * px, size.width, 60 * px);
        self.NameLable.textColor = [UIColor blackColor];
        self.NameLable.text = [NSString stringWithFormat:@"%@",AttendanceListModel.userName];
        self.NameLable.textAlignment = NSTextAlignmentLeft;
        self.NameLable.font = [UIFont systemFontOfSize:SYRealValue(26 / 2)];
        
        
        NSString * departmentStr = [NSString stringWithFormat:@"%@/%@",AttendanceListModel.stn_alias,AttendanceListModel.pst_alias];
        CGSize sizeStr = [departmentStr sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:SYRealValue(28 / 2)]}];
        self.departmentLabel.frame = CGRectMake(CGRectGetMaxX(self.NameLable.frame) + 10 * px, self.NameLable.y, sizeStr.width, self.NameLable.height);
        self.departmentLabel.textColor = [UIColor grayColor];
        self.departmentLabel.text = [NSString stringWithFormat:@"%@/%@",AttendanceListModel.stn_alias,AttendanceListModel.pst_alias];
        self.departmentLabel.textAlignment = NSTextAlignmentLeft;
        self.departmentLabel.font = [UIFont systemFontOfSize:SYRealValue(26 / 2)];
        
        
        self.SexButton.frame = CGRectMake(self.NameLable.x, CGRectGetMaxY(self.NameLable.frame) + 20 * px, 100 * px, 40 * px);
        if ([AttendanceListModel.gender isEqualToString:@"1"]) {
            [self.SexButton  setImage:[UIImage imageNamed:@"男"] forState:UIControlStateNormal];
            [self.SexButton setTitle:AttendanceListModel.age forState:UIControlStateNormal];
            self.SexButton.backgroundColor = WYCRGBColor(95, 207, 185);

        }else{
            [self.SexButton  setImage:[UIImage imageNamed:@"女"] forState:UIControlStateNormal];
            [self.SexButton setTitle:AttendanceListModel.age forState:UIControlStateNormal];
            self.SexButton.backgroundColor = WYCRGBColor(239, 138, 139);
        }
        self.SexButton.backgroundColor = WYCRGBColor(239, 138, 139);
        self.SexButton.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(20 / 2)];
        [self.SexButton  setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.SexButton.layer.cornerRadius = 5 * px;
        
        
        self.heightLabel.frame = CGRectMake(CGRectGetMaxX(self.SexButton.frame) + 10 * px, self.SexButton.y, 100 * px, self.SexButton.height);
        self.heightLabel.textColor = self.SexButton.titleLabel.textColor;
        self.heightLabel.text = [NSString stringWithFormat:@"%@cm",AttendanceListModel.height];
        self.heightLabel.layer.cornerRadius = 5 * px;
        self.heightLabel.backgroundColor = WYCRGBColor(109, 128, 152);
        self.heightLabel.textAlignment = NSTextAlignmentCenter;
        self.heightLabel.font = [UIFont systemFontOfSize:SYRealValue(20 / 2)];
        
        
        self.addressLabel.frame = CGRectMake(CGRectGetMaxX(self.heightLabel.frame) + 10 * px, self.SexButton.y, self.heightLabel.width, self.SexButton.height);
        self.addressLabel.textColor = [UIColor whiteColor];
        self.addressLabel.text = [NSString stringWithFormat:@"%@",AttendanceListModel.country];
        self.addressLabel.layer.cornerRadius = 5 * px;
        self.addressLabel.backgroundColor = WYCRGBColor(109, 128, 152);
        self.addressLabel.textAlignment = NSTextAlignmentCenter;
        self.addressLabel.font = [UIFont systemFontOfSize:SYRealValue(20 / 2)];
        
        //        self.lineView.backgroundColor = [UIColor redColor];
        self.lineView.hidden = YES;
        
//        [self.PhotoIMG sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",AttendanceListModel.avatarUrl]] placeholderImage:[UIImage imageNamed:@"我的占位头像"]];
//
////        CGSize size = [AttendanceListModel.userName sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:SYRealValue(28 / 2)]}];
////        self.NameLable.frame = CGRectMake(CGRectGetMaxX(self.PhotoIMG.frame) + 40 * px, self.PhotoIMG.y, size.width, 60 * px);
//        self.NameLable.text = [NSString stringWithFormat:@"%@",AttendanceListModel.userName];
//
//
//        CGSize departmentsize = [AttendanceListModel.userName sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:SYRealValue(28 / 2)]}];
//
//
////        self.departmentLabel.frame = CGRectMake(CGRectGetMaxX(self.NameLable.frame) + 10 * px, self.NameLable.y, departmentsize.width * 2, self.NameLable.height);
//
//        self.departmentLabel.text = [NSString stringWithFormat:@"%@/%@",AttendanceListModel.stn_alias,AttendanceListModel.pst_alias];
//
//        if ([AttendanceListModel.gender isEqualToString:@"1"]) {
//            [self.SexButton  setImage:[UIImage imageNamed:@"男"] forState:UIControlStateNormal];
//            [self.SexButton setTitle:AttendanceListModel.age forState:UIControlStateNormal];
//            self.SexButton.backgroundColor = WYCRGBColor(95, 207, 185);
//
//        }else{
//            [self.SexButton  setImage:[UIImage imageNamed:@"女"] forState:UIControlStateNormal];
//            [self.SexButton setTitle:AttendanceListModel.age forState:UIControlStateNormal];
//            self.SexButton.backgroundColor = WYCRGBColor(239, 138, 139);
//        }
//
//        self.heightLabel.text = [NSString stringWithFormat:@"%@cm",AttendanceListModel.height];
//
//
//        self.listNameLable.text = [NSString stringWithFormat:@"%@",AttendanceListModel.country];
//
//        self.addressLabel.text = [NSString stringWithFormat:@"%@",AttendanceListModel.country];
    }else{
        
        //列表
        
        /** 背景*/
        self.backView.frame = CGRectMake(0, 0, ScreenWidth , 300 * px);
        self.backView.backgroundColor = backgroundcolor;
        
        self.PhotoIMG.frame = CGRectMake(40 * px, 50 * px, 200 * px, 200 * px);
         [self.PhotoIMG sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",AttendanceListModel.avatarUrl]] placeholderImage:[UIImage imageNamed:@"我的占位头像"]];
        self.PhotoIMG.backgroundColor = [UIColor grayColor];
        
        CGSize size = [self.AttendanceListModel.userName sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:SYRealValue(28 / 2)]}];
        
        self.NameLable.frame = CGRectMake(CGRectGetMaxX(self.PhotoIMG.frame) + 40 * px, self.PhotoIMG.y, size.width, 60 * px);
        self.NameLable.textColor = [UIColor whiteColor];
        self.NameLable.text = [NSString stringWithFormat:@"%@",AttendanceListModel.userName];
        self.NameLable.textAlignment = NSTextAlignmentLeft;
        self.NameLable.font = [UIFont systemFontOfSize:SYRealValue(26 / 2)];
        
        
        self.SexButton.frame = CGRectMake(CGRectGetMaxX(self.NameLable.frame), self.NameLable.y + 10 * px, 100 * px, 40 * px);
        if ([AttendanceListModel.gender isEqualToString:@"1"]) {
            [self.SexButton  setImage:[UIImage imageNamed:@"男"] forState:UIControlStateNormal];
            [self.SexButton setTitle:AttendanceListModel.age forState:UIControlStateNormal];
            self.SexButton.backgroundColor = WYCRGBColor(95, 207, 185);
        }else{
            [self.SexButton  setImage:[UIImage imageNamed:@"女"] forState:UIControlStateNormal];
            [self.SexButton setTitle:AttendanceListModel.age forState:UIControlStateNormal];
            self.SexButton.backgroundColor = WYCRGBColor(239, 138, 139);
        }
        //        self.SexButton.backgroundColor = WYCRGBColor(239, 138, 139);
        self.SexButton.titleLabel.font = [UIFont systemFontOfSize:SYRealValue(20 / 2)];
        [self.SexButton  setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.SexButton.layer.cornerRadius = 5 * px;
        
        self.departmentLabel.frame = CGRectMake(self.NameLable.x, CGRectGetMaxY(self.NameLable.frame) + 20 * px, 400 * px, self.NameLable.height);
        self.departmentLabel.textColor = [UIColor grayColor];
        self.departmentLabel.text = @"部门:(营业部)";
        self.departmentLabel.textAlignment = NSTextAlignmentLeft;
        self.departmentLabel.font = [UIFont systemFontOfSize:SYRealValue(26 / 2)];
        
        
        self.heightLabel.frame = CGRectMake(self.NameLable.x, CGRectGetMaxY(self.departmentLabel.frame) + 15 * px, 100 * px, 40 * px);
        self.heightLabel.textColor = [UIColor whiteColor];
        self.heightLabel.backgroundColor = [UIColor clearColor];
        self.heightLabel.text = [NSString stringWithFormat:@"%@cm",AttendanceListModel.height];
        self.heightLabel.backgroundColor = WYCRGBColor(109, 128, 152);
        self.heightLabel.textAlignment = NSTextAlignmentCenter;
        self.heightLabel.font = [UIFont systemFontOfSize:SYRealValue(20 / 2)];
        
        
        self.addressLabel.frame = CGRectMake(CGRectGetMaxX(self.heightLabel.frame) + 10 * px, self.heightLabel.y, self.heightLabel.width, self.heightLabel.height);
        self.addressLabel.textColor = [UIColor whiteColor];
        self.addressLabel.text = [NSString stringWithFormat:@"%@",AttendanceListModel.country];
        self.addressLabel.layer.cornerRadius = 5 * px;
        self.addressLabel.backgroundColor = WYCRGBColor(109, 128, 152);
        self.addressLabel.textAlignment = NSTextAlignmentCenter;
        self.addressLabel.font = [UIFont systemFontOfSize:SYRealValue(20 / 2)];
        
        
        self.speLabel.frame = CGRectMake(CGRectGetMaxX(self.addressLabel.frame) + 10 * px, self.heightLabel.y, self.heightLabel.width, self.heightLabel.height);
        self.speLabel.textColor = [UIColor whiteColor];
        if ([AttendanceListModel.speciality isEqualToString:@"1"]) {
            self.speLabel.text = @"歌曲";
        }else if ([AttendanceListModel.speciality isEqualToString:@"2"]) {
            self.speLabel.text = @"舞蹈";
        }else if ([AttendanceListModel.speciality isEqualToString:@"3"]) {
            self.speLabel.text = @"外语";
        }else{
            self.speLabel.text = @"其他";
        }
        //        self.speLabel.text = @"中国河北";
        self.speLabel.layer.cornerRadius = 5 * px;
        self.speLabel.backgroundColor = WYCRGBColor(109, 128, 152);
        self.speLabel.textAlignment = NSTextAlignmentCenter;
        self.speLabel.font = [UIFont systemFontOfSize:SYRealValue(20 / 2)];
        
        self.attendanceLabel.frame = CGRectMake(ScreenWidth - 180 * px ,self.backView.height / 2 - 30 * px, 150 * px, self.NameLable.height);
        self.attendanceLabel.textAlignment = NSTextAlignmentCenter;
        if ([AttendanceListModel.state isEqualToString:@"1"]) {
            self.attendanceLabel.text = @"已服务";
            self.attendanceLabel.backgroundColor = WYCRGBColor(37, 38, 47);
            self.attendanceLabel.textColor = WYCRGBColor(191, 86, 48);
        }else{
            self.attendanceLabel.text = @"未服务";
            self.attendanceLabel.backgroundColor = WYCRGBColor(33, 50, 47);
            self.attendanceLabel.textColor = WYCRGBColor(96, 134, 52);
        }
        self.attendanceLabel.font = [UIFont systemFontOfSize:SYRealValue(26 / 2)];
        
        self.lineView.frame = CGRectMake(280 * px, 300 * px - 1, ScreenWidth - 280 * px, 1);
        self.lineView.backgroundColor = BackViewColor;
        
        
//        [self.PhotoIMG sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",AttendanceListModel.avatarUrl]] placeholderImage:[UIImage imageNamed:@"我的占位头像"]];
//
//
//        self.NameLable.text = [NSString stringWithFormat:@"%@",AttendanceListModel.userName];
//
//        self.departmentLabel.text = [NSString stringWithFormat:@"%@/%@",AttendanceListModel.stn_alias,AttendanceListModel.pst_alias];
//
//
//        if ([AttendanceListModel.gender isEqualToString:@"1"]) {
//            [self.SexButton  setImage:[UIImage imageNamed:@"男"] forState:UIControlStateNormal];
//            [self.SexButton setTitle:AttendanceListModel.age forState:UIControlStateNormal];
//            self.SexButton.backgroundColor = WYCRGBColor(95, 207, 185);
//        }else{
//            [self.SexButton  setImage:[UIImage imageNamed:@"女"] forState:UIControlStateNormal];
//            [self.SexButton setTitle:AttendanceListModel.age forState:UIControlStateNormal];
//            self.SexButton.backgroundColor = WYCRGBColor(239, 138, 139);
//        }
//
//        self.heightLabel.text = [NSString stringWithFormat:@"%@cm",AttendanceListModel.height];
//
//
//        self.listNameLable.text = [NSString stringWithFormat:@"%@",AttendanceListModel.country];
//
//        self.addressLabel.text = [NSString stringWithFormat:@"%@",AttendanceListModel.country];
//
//        if ([AttendanceListModel.state isEqualToString:@"1"]) {
//            self.attendanceLabel.text = @"已服务";
//            self.attendanceLabel.backgroundColor = WYCRGBColor(37, 38, 47);
//            self.attendanceLabel.textColor = WYCRGBColor(191, 86, 48);
//        }else{
//            self.attendanceLabel.text = @"未服务";
//            self.attendanceLabel.backgroundColor = WYCRGBColor(33, 50, 47);
//            self.attendanceLabel.textColor = WYCRGBColor(96, 134, 52);
//        }
//
//        if ([AttendanceListModel.speciality isEqualToString:@"1"]) {
//            self.speLabel.text = @"歌曲";
//        }else if ([AttendanceListModel.speciality isEqualToString:@"2"]) {
//            self.speLabel.text = @"舞蹈";
//        }else if ([AttendanceListModel.speciality isEqualToString:@"3"]) {
//            self.speLabel.text = @"外语";
//        }else{
//            self.speLabel.text = @"其他";
//        }
//
    }
    
    
//    self.attendanceLabel.text = [NSString stringWithFormat:@"打卡时间:%@",AttendanceListModel.attendTime];
}
@end
